package com.qch.rocket.demo.producer;

import org.apache.rocketmq.client.exception.MQBrokerException;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.remoting.exception.RemotingException;

/**
 * @Author qch
 * @Date 2021/6/10
 */
public class MyProducer {
    public static void main(String[] args) throws InterruptedException, RemotingException, MQClientException, MQBrokerException {
        DefaultMQProducer producer = new DefaultMQProducer("producer_grp_13_01");
        producer.setNamesrvAddr("192.168.142.134:9876");
        producer.start();
        Message message=null;
        for (int i = 0; i < 1000; i++) {
            message=new Message("tp_demo_13",("hello sentinel"+i).getBytes());
            producer.send(message);
        }
        producer.shutdown();
    }

}
